      SUBROUTINE QUIKVIS5A2C1(IREQ,ANOMLY,BAR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE QUIKVIS PROGRAM.  IT IS USED TO LOAD THE
C 121-CHARACTER VARIABLE NAMED 'BAR' THAT IS USED TO DISPLAY TARGET
C AVAILABILITY FOR A SPECIFIC TIME, RAAN, AND OBSERVATION REQUIREMENT.
C THE BAR SHOWS THE AVAILABILITY MEAN ANOMALY RELATIVE TO THE ORBIT
C EVENT IDENTIFIED BY THE KRELTIME GLOBAL PARAMETER(IN QUIKVIS.INC).
C
C VARIABLE DIM TYPE I/O DESCRIPTION
C -------- --- ---- --- -----------
C
C IREQ      1   I*4  I  PRESENT FOR DEBUG USE ONLY.  THE OBSERVATION
C                       REQUIREMENT NUMBER(1=HORIZON, 2=NIGHT,...)
C                       INVOLVED ON THIS CALL.
C
C ANOMLY    2   R*8  I  RELATIVE MEAN ANOMALY RANGE WHERE THE CURRENT
C                       REQUIREMENT IS SATISFIED.  ANOMLY(1) IS THE
C                       START VALUE, ANOMLY(2) THE END VALUE.
C                       IN RADIANS.
C
C BAR       1 CH*121 O  121-CHARACTER STRING, EACH STRING ELEMENT BEING
C                       ASSOCIATED WITH A 3-DEGREE RANGE OF RELATIVE
C                       MEAN ANOMALY, THE FIRST ELEMENT REPRESENTING THE
C                       0-3 RANGE, THE SECOND THE 3-6 RANGE, ETC.  THE
C                       121-ST ELEMENT REPRESENTS THE 360 DEGREE VALUE.
C
C                       IF THE ELEMENT IS '*', THE REQUIREMENT IS
C                       SATISFIED IN THAT ELEMENT'S RANGE.  IF BLANK, IT
C                       IS NOT SATISFIED.
C
C***********************************************************************
C
C BY C PETRUZZO/GFSC/742.   2/86.
C       MODIFIED.... 9/86. CJP.  EXTENSIVE MODS TO MORE ACCURATELY FILL
C                                THE 121 PRINT POSITIONS;  PROBLEMS
C                                TENDED TO OCCUR WHEN 2PI WAS CROSSED;
C                                REPLACED TAREQ ARRAY WITH ANOMLY ARRAY;
C                                ADDED IREQ TO ARGUMENT LIST FOR DEBUG.
C
C***********************************************************************
C
      INCLUDE 'QUIKVIS.INC'
C
      REAL*8 ANOMLY(2)
      REAL*8 TOLER/0.D0/
      CHARACTER*121 BAR
      LOGICAL ALWAYS,NEVER
C
      IBUG = 0
      LUBUG = 19
C
      IF(IBUG.NE.0) WRITE(LUBUG,9001)
     *        IREQ,ANOMLY(1)*DEGRAD,ANOMLY(2)*DEGRAD
 9001 FORMAT(' QUIKVIS5A2C1.  IREQ=',I2,'  ANOMLY=',2G23.16)
C
C
C INITIALIZE
C
      ANOM1 = ANOMLY(1)
      ANOM2 = ANOMLY(2)
C
C
C ERROR CHECK. THIS ROUTINE IS CODED WITH THE EXPECTATION THAT
C ANOMLY(1) LT/EQ ANOMLY(2).  IF NOT, STOP TO FORCE A LOOK.
C
      IF(ANOM2.LT.ANOM1)
     *     STOP 'QUIKVIS5A2C1. CODING ERROR. STOP 1. SEE SOURCE.'
C
C
C SET THE TOLERANCE ANGLE USED TO DETERMINE WHETHER EXACTLY ZERO OR
C EXACTLY TWOPI IS INTENDED FOR THE ANOMLY INPUT VALUES.
C
      IF(TOLER.EQ.0.D0) THEN
        TOLER = (1.D0/3600.D0) / DEGRAD  ! = 1 ARC SEC
        TOLER2 = 2.D0 * TOLER  ! USED WHEN TESTING A SUM OR DIFFERENCE
        END IF
C
C
C ASSIGN 121 PRINT POSITIONS TO THE 360 DEGREE ANOMALY RANGE, THEN
C PUT *'S IN PRINT POSITIONS FOR THE ANOMALIES WHERE THE TARGET IS
C AVAILABLE.  ZERO AND 360 ARE EQUIVALENT, BUT USE TWO POSITIONS FOR
C EASIER READING.  THIS CODE WOULD BE SIMPLER IF WE DID NOT HAVE TO
C ACCOUNT FOR THE ROUNDING EFFECTS AT THE ZERO AND TWOPI POSITIONS.
C
      ALWAYS = DABS( (ANOM2-ANOM1)-TWOPI ) .LE. TOLER2
      NEVER =  ANOM2-ANOM1 .LE. TOLER2
C
      IF(ALWAYS) THEN
        ANOM1 = 0.D0
        ANOM2 = TWOPI
C
      ELSE IF(NEVER) THEN
        CONTINUE
C
      ELSE
        ANOM1 = EQVANG(ANOMLY(1))
        ANOM2 = EQVANG(ANOMLY(2))
C      ACCOUNT FOR POSSIBLE ROUNDING ERROR IN ANOM1.
        IF(ANOM1.LT.TOLER) THEN
          ANOM1 = 0.D0
        ELSE IF(DABS(ANOM1-TWOPI).LT.TOLER) THEN
          ANOM1 = 0.D0
          END IF
C      ACCOUNT FOR POSSIBLE ROUNDING ERROR IN ANOM2.
        IF(ANOM2.LT.TOLER) THEN
          ANOM2 = 0.D0
        ELSE IF(DABS(ANOM2-TWOPI).LT.TOLER) THEN
          ANOM2 = TWOPI
          END IF
C      BE SURE THE ANOM2 VALUE IS GREATER THAN THE ANOM1 VALUE.
        IF(ANOM2.LT.ANOM1) ANOM2 = ANOM2 + TWOPI
        END IF
C
      IF(IBUG.NE.0) WRITE(LUBUG,9002)
     *    ALWAYS,NEVER,ANOM1*DEGRAD,ANOM2*DEGRAD
 9002 FORMAT(' QUIKVIS5A2C1.  ALWAYS,NEVER=',2L2,
     *            '  ANOM1,ANOM2=',2G23.16)
C
      BAR = ' '
C
C    IF THE REQUIREMENT IS SATISFIED AT LEAST PART OF THE TIME, PUT *'S
C    IN THE APPROPRIATE POSITIONS IN THE BAR STRING.
      IF(.NOT.NEVER) THEN
        DELBAR =     TWOPI/120.D0
        K1 = (ANOM1+TOLER)/DELBAR + 1
        K2 = (ANOM2+TOLER)/DELBAR + 1
        IF(IBUG.NE.0) WRITE(LUBUG,9003) K1,K2,DELBAR*DEGRAD
 9003   FORMAT(' QUIKVIS5A2C1.  K1,K2=',2I4,'   DELBAR=',G23.16)
        DO I=K1,K2
          ICH = I
          IF(ICH.NE.121) THEN  ! POSITION 121 IS HANDLED LATER.
            IF(ICH.GT.120) ICH = ICH - 120
            BAR(ICH:ICH) = '*'
            END IF
          END DO
C      FOR BARS THAT END ON OR CROSS 2PI, MAKE SURE THE ZERO AND 2PI
C      POSITIONS ARE SET PROPERLY.
        IF(DABS(ANOM2-TWOPI).LT.TOLER) BAR(121:121) = '*'
        IF(ANOM2.GT.(TWOPI+TOLER)) THEN
          BAR(  1:  1) = '*'
          BAR(121:121) = '*'
          END IF
        END IF
 
      RETURN
C
C***********************************************************************
C
C
C**** INITIALIZATION CALL. PUT GLOBAL PARAMETER VALUES INTO THIS
C     ROUTINE'S LOCAL VARIABLES.
C
      ENTRY QVINIT5A2C1
C
      CALL QUIKVIS999(-1,R8DATA,I4DATA,L4DATA)
      RETURN
C
C***********************************************************************
C
      END
